/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.eisti.icc.zk;

import fr.eisti.icc.client.ClientBibliotheque;
import com.sun.jersey.api.client.ClientResponse;
import fr.eisti.icc.data.Emprunteur;
import java.util.HashMap;
import java.util.Map;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Div;
import org.zkoss.zul.East;
import org.zkoss.zul.Image;
import org.zkoss.zul.Label;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.West;
import org.zkoss.zul.Window;

/**
 *
 * @author clion
 */
public class EditProfile extends GenericForwardComposer {

    Label promo;
    Label numero;
    Label tel;
    Label adresse;
    Label name;

    public void onClick$editer() {
        String[] nomPrenom = name.getValue().split(" ");

        ClientBibliotheque cl = new ClientBibliotheque();
        Session session = Executions.getCurrent().getSession();
        Emprunteur emp = cl.getClientByLogin_XML(Emprunteur.class, session.getAttribute("user") + "");
        newInscription(emp);
        cl.close();
    }

    public static void newInscription(Emprunteur emp) {
        Map dataProfil = new HashMap();
        if (emp.isEstAdmin()) {
            dataProfil.put("promo", "");
        } else if (emp.isEstProf()) {
            dataProfil.put("promo", "");

        } else {
            dataProfil.put("promo", emp.getPromo());
        }



        dataProfil.put("numCarte", emp.getNumCarte());
        dataProfil.put("tel", emp.getTel());
        dataProfil.put("adresse", emp.getAdresse());
        dataProfil.put("nom", emp.getNom());
        dataProfil.put("prenom", emp.getPrenom());
        dataProfil.put("dateNaissance", emp.getDateNaissance());
        Window window = (Window) Executions.createComponents(
                "inscription.zul", null, dataProfil);
        window.onModal();
    }
}
